package com.stu.dao.impl;

import com.stu.dao.RowMapper;
import com.stu.entity.Dept;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * 实现RowMapper接口,接收Dept对象
 * @author zy
 * @date 2025/3/4 16:29
 */
public class DeptRowMapper implements RowMapper<Dept> {
    @Override
    public Dept mapper(ResultSet rs) {
        Dept dept = null;

        try {
            int deptno = rs.getInt(1);
            String dname = rs.getString(2);
            String loc = rs.getString(3);

            dept = new Dept(deptno, dname, loc);

        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

        return dept;
    }
}
